package com.spzx.user.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.domain.AjaxResult;
import com.spzx.user.api.RemoteUserAddressService;
import com.spzx.user.api.domain.UserAddress;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * ClassName: RemoteUserAddressInfoFallbackFactory
 * Package: com.spzx.user.api.factory
 * Description:
 */
@Slf4j
@Component
public class RemoteUserAddressFallbackFactory implements FallbackFactory {

    @Override
    public Object create(Throwable cause) {
        log.error("调用用户模块的地址失败:{}",cause.getMessage());
        return new RemoteUserAddressService() {
            @Override
            public R<UserAddress> getInfo(Long id, String source) {
                return R.fail("获取地址失败:" + cause.getMessage());
            }
        };
    }
}
